package com.isoftstone.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @Author: zhaojg
 * @Description
 * @Date: Created in 18:16 2018/1/4
 * @Modified by:
 */
public class MyListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {

    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

//    private MyThread myThread;
//    public void contextDestroyed(ServletContextEvent e) {
//        if (myThread != null && myThread.isInterrupted()) {
//            myThread.interrupt();
//        }
//    }
//    public void contextInitialized(ServletContextEvent e) {
//        String str = null;
//        if (str == null && myThread == null) {
//            myThread = new MyThread();
//            myThread.start(); // servlet 上下文初始化时启动 socket
//        }
//    }
//
//    class MyThread extends Thread {
//        public void run() {
//            while (!this.isInterrupted()) {// 线程未中断执行循环
//                try {
//                    Thread.sleep(2000); //每隔2000ms执行一次
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
////           ------------------ 开始执行 ---------------------------
//                System.out.println("____FUCK TIME:" + System.currentTimeMillis());
//            }
//        }
//    }
}
